/******************************************************************************
 * * setting_security.h - data structure for setting security sub-module
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#ifndef SETTING_SECURITY_H
#define SETTING_SECURITY_H

#ifdef __cplusplus
extern "C" {
#endif

#define SETTING_SECURITY_PIN_CODE_LEN    4
#define SETTING_SECURITY_PUK_CODE_LEN    8

typedef enum
{
    SETTING_ACC_CODE_CHG_OFF = 0,                                               // access code not changing
    SETTING_SECURITY_OLD_ENTERING,                                              // old security code entering
    SETTING_SECURITY_NEW_ENTERING,                                              // new security code entering
    SETTING_SECURITY_NEW_VERIFYING,                                             // verifying new security code
    SETTING_PIN_OLD_ENTERING,                                                   // old PIN code entering
    SETTING_PIN_NEW_ENTERING,                                                   // new PIN code entering
    SETTING_PIN_NEW_VERIFYING,                                                  // verifying new PIN code
    SETTING_PUK_ENTERING,                                                       // PUK code entering
    SETTING_PIN_NEW_ENTERING_PUK_CHK,                                           // new PIN code entering(during PUK check)
    SETTING_PIN_NEW_VERIFYING_PUK_CHK,                                          // verifying new PIN code(during PUK check)
    SETTING_PIN2_OLD_ENTERING,                                                  // old PIN2 code entering
    SETTING_PIN2_NEW_ENTERING,                                                  // new PIN2 code entering
    SETTING_PIN2_NEW_VERIFYING,                                                 // verifying new PIN2 code
    SETTING_PUK2_ENTERING,                                                      // PUK2 code entering
    SETTING_PIN2_NEW_ENTERING_PUK2_CHK,                                         // new PIN2 code entering(during PUK2 check)
    SETTING_PIN2_NEW_VERIFYING_PUK2_CHK,                                        // verifying new PIN2 code(during PUK2 check)
} SETTING_ACC_CODE_CHG_STATUS;

typedef enum
{
    SETTING_PIN_REQUEST_POWERON = 0,                                            // power on the first time pin request
    SETTING_PIN_REQUEST_NORMAL,                                                 // pin request after power on(e.g. exit flight mode)
} SETTING_PIN_REQ_STATUS;

typedef enum
{
    SETTING_PIN_OPERATION_OFF = 0,
    SETTING_PIN_OPERATION_PIN1,                                                 // PIN1 operating
    SETTING_PIN_OPERATION_PUK1,                                                 // PUK1 operating
    SETTING_PIN_OPERATION_PUK1_PIN_NEW_ENTERING,                                // PUK1 operating, input new PIN
    SETTING_PIN_OPERATION_PUK1_PIN_NEW_VERIFYING,                               // PUK1 operating, verify new PIN
    SETTING_PIN_OPERATION_PIN2,                                                 // PIN2 operating
    SETTING_PIN_OPERATION_PUK2,                                                 // PUK2 operating
} SETTING_PIN_OPERATION_TYPE;

typedef enum
{
    SETTING_SECURITY_ACTION_NONE = 0,                                           // ACTION NONE
    SETTING_SECURITY_ACTION_PIN_CODE_REQUEST,                                   // PIN code request, setting menu
    SETTING_SECURITY_ACTION_PHONE_SECURITY,                                     // phone security, setting menu
    SETTING_SECURITY_ACTION_CHG_ACC_CODE,                                       // change access code, setting menu
    SETTING_SECURITY_ACTION_EXT_PIN_CHK_NO_CNF,                                 // external PIN check, no cnf
    SETTING_SECURITY_ACTION_EXT_PIN_CHK_WITH_CNF,                               // external PIN check, with cnf(from framework)
    SETTING_SECURITY_ACTION_EXT_SECURITY_CODE_CHK,                              // external security code check
    SETTING_SECURITY_ACTION_EXT_SECURITY_KEYGUARD_CODE_CHK,                     // external security key guard code check
} SETTING_SECURITY_OPERATION_ACTION_TYPE;

typedef struct
{
    BOOL                                   IsPinRequest[2];                               // true means PIN requested
    BOOL                                   IsPinTrying;                                   // true or false
    INT8                                   SecurityCode[NV_SETTING_SECURITY_CODE_LEN];    // 4 bytes security code
    INT8                                   NewSecurityCode[NV_SETTING_SECURITY_CODE_LEN]; // 4 bytes new security code
    INT8                                   NewPinCode[SETTING_SECURITY_PIN_CODE_LEN];     // 4 bytes new pin code, for new pin verifying
    INT8                                   OldPinCode[SETTING_SECURITY_PIN_CODE_LEN];     // 4 bytes new pin code, for changing pin
    INT8                                   PukCode[SETTING_SECURITY_PUK_CODE_LEN];        // 8 bytes puk code, for puk checking
    BOOL                                   IsSecurityOn;                                  // true means security code requested on
    SETTING_ACC_CODE_CHG_STATUS            AccCodeChgStatus;                              // status for access code changing
    SETTING_PIN_OPERATION_TYPE             PinOperatingType;                              // pin operating type
    MMI_MODEM_SIM_ID                       OperatingSIM;                                  // SIM Id who is in operating status
    SETTING_SECURITY_OPERATION_ACTION_TYPE OperatingAction;                               // SIM Id who is in operating status
} Setting_Security_Setting_Mng_t;

extern Setting_Security_Setting_Mng_t g_SettingSecuritySettingMng;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*SETTING_SECURITY_H*/
